﻿using System;


namespace epicenter2010.ValueObjects
{
	/// <summary>
	/// bstack @ 06/06/2010
	/// Money value object, note immutability
	/// </summary>
	public class Money
	{
		/// <summary>
		/// Currency
		/// </summary>
		public readonly string Currency;

		/// <summary>
		/// Amount
		/// </summary>
		public readonly decimal Amount;


		/// <summary>
		/// Ctor
		/// </summary>
		/// <param name="currency"></param>
		/// <param name="amount"></param>
		public Money(
			string currency,
			decimal amount)
		{
			epicenter2010.Common.DBCChecker.RequireArgumentNotEmpty("currency", currency);
			epicenter2010.Common.DBCChecker.Require(amount > 0, "Invalid amount");

			this.Currency = currency;
			this.Amount = amount;
		}


		/// <summary>
		/// Equals
		/// </summary>
		/// <param name="other"></param>
		/// <returns></returns>
		public bool Equals(
			epicenter2010.ValueObjects.Money subject)
		{
			epicenter2010.Common.DBCChecker.RequireArgumentNotNull("subject", subject);

			return ((this.Currency == subject.Currency) && (this.Amount == subject.Amount));
		}
	}
}

